<?php
class commonControl extends Control{
    function index(){
		
		$id=$_GET["id"];
		//echo "这是评论页面";
		$db=M("news");
		$row=$db->where("id=$id")->field("title")->all();
		$db=K("commentview");
		$count = $db->where("nid=$id")->count();
                $page = new page($count, 5);
		$news=$db->where("nid=$id")->join("user")->limit($page->limit())->all();
		//p($news);
		//p($row);
		$this->assign("news",$news);
		$this->assign("row",$row);
		$this->assign("page", $page->show(2));
		$this->display();
	}
	
	 function allcomment(){
		//$db=M("news");
		//$row=$db->field("title")->all();
		$db=K("commentview");
		$count = $db->count();
                $page = new page($count, 5);
		$news=$db->join("user")->limit($page->limit())->all();
		//p($news);
		//p($row);
		$this->assign("news",$news);
		//$this->assign("row",$row);
		$this->assign("page", $page->show(2));
		$this->display("index");
	
	}
	
	
		 function pingbi(){
		
		$db=K("commentview");
		$count = $db->where("stat=0")->count();
        $page = new page($count, 5);
		$news=$db->join("user")->where("stat=0")->limit($page->limit())->all();
		$this->assign("news",$news);
		$this->assign("page", $page->show(2));
		$this->display("index");
	
	}
	
	
	
	
	
	
	
	
	
	function del(){
		$cid=$_GET["id"];
		$nid=$_GET["nid"];
		//p($nid);exit;
		//p($stat);exit;
		$db=M("comment");
		if($db->where("cid=$cid")->del()){
			$sql  = " update hd_news set replycount=replycount-1 where id='$nid' ";
			$db->exe($sql);
			$this->success("删除评论成功！");
		}else{
			$this->error("删除配置失败！");
		}
	
	}
	
	function hidden(){
	$cid=$_GET["id"];
		$stat=$_GET["stat"];
		//p($stat);exit;
		$db=M("comment");
		
		if($stat){
			if($db->save(array("cid"=>$cid,"stat"=>0))){
				$this->success("屏蔽评论成功！");
			}else{
				$this->error("屏蔽评论失败！");
			};
		}else{
			if($db->save(array("cid"=>$cid,"stat"=>1))){
			$this->success("显示评论成功！");
			}else{
				$this->error("显示评论失败！");
			};
		}
	}
}

?>
